package tech.yangzhijie.basic.ioc;



import java.util.ArrayList;
import java.util.List;

public class UserDao {

    private static List<User> users;

    static {
        User u1 = new User(1,"杨幂","上海",5000.0);
        User u2 = new User(2,"刘亦菲","武汉",20000.0);
        User u3 = new User(3,"郭采洁","武汉",10000.0);

        users = new ArrayList<>();
        users.add(u1);
        users.add(u2);
        users.add(u3);
    }

    public User selectUserById(Integer id){
        return users.stream().filter(e->e.getId()==id).findFirst().get();
    }

    public List<User> selectUserAll(){
        return users;
    }
}
